package connection.replies;

import interfaces.clients.dispatcher.replies.BaseReply;
import java.io.ObjectInputStream;

/** @author Mihail A. Muhin */
public class RepliesReader {
  public static BaseReply read(ObjectInputStream ois) {
    BaseReply res = null;
    try {
      String class_name = null;
      class_name = (String) (ois.readObject());
      res = (BaseReply) (
              Class.forName(
                      RepliesReader.class.getPackage().getName().concat(".").concat(class_name)
              ).newInstance()
      );
      res.read(ois);
    } catch (Exception e) {
      e.printStackTrace();
    }
    return res;
  }

  private RepliesReader() {

  }
}
